package edu.must.uh.util;

public class R {
    
    private int code; // 200是正常，非200表示异常
    private String msg;
    private Object data;
    private Long count;
    

    public static R succ() {
        return succ(0, "操作成功", null);
    }
    public static R succ(Object data) {
        return succ(0, "操作成功", data);
    }
    public static R succ(Object data,Long count) {
        return succ(0, "操作成功", data,count);
    }

    public static R succ(int code, String msg, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    
    public static R succ(int code, String msg, Object data,Long count) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        r.setCount(count);
        return r;
    }
    
    public static R fail() {
        return fail(400, "操作失敗", null);
    }
    public static R fail(String msg) {
        return fail(400, msg, null);
    }

    public static R fail(String msg, Object data) {
        return fail(400, msg, data);
    }

    public static R fail(int code, String msg, Object data) {
        R r = new R();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }
    
    

    public Long getCount() {
        return count;
    }
    public void setCount(Long count) {
        this.count = count;
    }
    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getMsg() {
        return msg;
    }
    public void setMsg(String msg) {
        this.msg = msg;
    }
    public Object getData() {
        return data;
    }
    public void setData(Object data) {
        this.data = data;
    }

}
